package com.market.service.admin.impl;

import com.market.bean.common.BaseStatVo;
import com.market.bean.vo.admin.AdminStatGoodsVo;
import com.market.bean.vo.admin.AdminStatOrderVo;
import com.market.bean.vo.admin.AdminStatUserVo;
import com.market.mapper.MarketGoodsMapper;
import com.market.mapper.MarketOrderGoodsMapper;
import com.market.mapper.MarketUserMapper;
import com.market.service.admin.AdminStatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author fan
 * @Description:
 * @since 2022/12/30 15:25
 */
@Service
public class AdminStatServiceImpl implements AdminStatService {
    @Autowired
    MarketUserMapper userMapper;
    @Autowired
    MarketGoodsMapper goodsMapper;
    @Autowired
    MarketOrderGoodsMapper orderGoodsMapper;

    @Override
    public BaseStatVo<AdminStatUserVo> user() {
        List<AdminStatUserVo> list = userMapper.GroupByDayToUser();
        BaseStatVo<AdminStatUserVo> data = new BaseStatVo<>(new AdminStatUserVo());
        data.setRows(list);
        return data;
    }

    @Override
    public BaseStatVo<AdminStatOrderVo> order() {
        List<AdminStatOrderVo> list = goodsMapper.GroupByDayToOrder();
        BaseStatVo<AdminStatOrderVo> data = new BaseStatVo<>(new AdminStatOrderVo());
        data.setRows(list);
        return data;
    }

    @Override
    public BaseStatVo<AdminStatGoodsVo> goods() {
        List<AdminStatGoodsVo> list = orderGoodsMapper.GroupByDayToOrderGoods();
        BaseStatVo<AdminStatGoodsVo> data = new BaseStatVo<>(new AdminStatGoodsVo());
        data.setRows(list);
        return data;
    }
}
